<template>
	<!-- 业务流程表单 -->
	<view class="container">
		<u-form :model="form" ref="uForm" label-width="200">
		  <u-form-item label="任务名称"
		    ><u-input v-model="form.name" disabled
		  /></u-form-item>
		  <u-form-item label="所属流程"
		    ><u-input v-model="form.belong" disabled
		  /></u-form-item>
		  <u-form-item label="申请人"
		    ><u-input v-model="formData.applicant" disabled
		  /></u-form-item>
		  <u-form-item label="委托人"
		    ><u-input v-model="form.client" disabled
		  /></u-form-item>
		  <u-form-item label="流程发起人"
		    ><u-input v-model="form.initiator" disabled
		  /></u-form-item>
		  <u-form-item label="优先级"
		    ><u-input v-model="form.priority" disabled class="input-color"
		  /></u-form-item>
		  <u-form-item label="状态"
		    ><u-input v-model="form.status" disabled
		  /></u-form-item>
		  <u-form-item label="业务开始时间">
		    <u-input v-model="formData.businessBegin" disabled/>
		  </u-form-item>
		  <u-form-item label="业务结束时间">
		    <u-input v-model="formData.businessEnd" disabled/>
		  </u-form-item>
		  <u-form-item label="业务说明">
			<u-input v-model="formData.businessRemark" disabled
		  /></u-form-item>
		  <u-form-item label="创建时间">
		    <u-input v-model="form.time" disabled />
		  </u-form-item>
		</u-form>
	</view>
</template>

<script>
	import auditApi from "../../api/audit.js";
	import getNameApi from "../../api/getName.js";
	export default {
		name:"business",
		props:['form'],
		data() {
			return {
				formData:{
					applicant:'无',
					businessRemark:'',
					businessBegin:'',
					businessEnd:''
				}
			};
		},
		mounted() {
			setTimeout(()=>{
				this.getData()
			},0)
		},
		methods:{
			async getData(){
				//获取表单信息
				const res1 = await auditApi.getAuditDetail(
					{"X-Access-Token": this.$store.state.token},
					this.form.table)
				let {
					businessBy,
					businessRemark,
					businessBegin,
					businessEnd
				} = res1.data.result;
				this.formData.businessRemark = businessRemark || '无';
				this.formData.businessBegin = businessBegin || '无';
				this.formData.businessEnd = businessEnd || '无';
				//通过userName查询用户名称
				  if(businessBy){
					const res2 = await getNameApi.getUserName(
						{
						  "X-Access-Token": this.$store.state.token,
						},
						{username:businessBy}
					  )
					  this.formData.applicant = res2.data.result.records[0].realname
				  }
			}
		}
	}
</script>

<style scoped lang="scss">
.container {
  width: 90%;
  margin: 0 auto;
}
</style>